<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:include="base/head::head"/>
<body>
<form id="form" method="post" style="padding: 10px; width: 800px; margin: 0px auto">
    <input id="formName" name="formName" th:value="${formName}"/>
    <input id="tableName" name="tableName" th:value="${tableName}"/>
    <div>
        <label for="code">编码:</label>
        <input class="easyui-textbox" style="width: 200px" data-operator="like" data-field="code" id="code" name="code"/>
        <label for="title">标题:</label>
        <input class="easyui-textbox" style="width: 200px" data-operator="like" data-field="title" id="title" name="title"/>
    </div>
    <div>
        <label for="dnum">数量:</label>
        <input class="easyui-numberspinner" id="dnum" name="dnum" data-operator="=" data-field="dnum"/>
        <label for="start_create_time">开始时间:</label>
        <input class="easyui-datebox" id="start_create_time" name="start_create_time" data-operator=">=" data-field="create_time"/>
        <label for="end_create_time">结束时间:</label>
        <input class="easyui-datebox" id="end_create_time" name="end_create_time" data-operator="<=" data-field="create_time"/>
    </div>
</form>
<button onclick="onTest()">test</button>
<script>
    function onTest() {
        alert(onQuery());
    }

    function onQuery() {
        // 校验
        var bool = $("#form").form("validate");
        if (bool == false) {
            // AlertUtil.error("请输入必输项！");
            return;
        }
        var items = $("#form").serializeArray();
        var querys = [];
        for (var i = 0; i < items.length; i++) {
            var fieldName = items[i].name;
            if (fieldName == "formName" || fieldName == "tableName") {
                continue;
            }
            var fieldValue = items[i].value;
            var inputField = $("input[id=" + fieldName + "]");
            if (fieldValue != "") {
                querys.push({"field": inputField.data("field"), "opt": inputField.data("operator"), "value": fieldValue});
            }
        }
        return querys;
    }
</script>
</body>
</html>